<template>
  <div>
    <we-nav-bar></we-nav-bar>
    <van-tabs v-model="active" color="#3E76D7">
      <van-tab title="医疗服务">
        <van-search
          placeholder="请输入医疗服务名称"
          v-model="FuWuSoso_val"
          @search="FuWuSoso_soso"
        />
        <van-cell
          v-for="(item, index) of FuWuSoso_data"
          :title="item.Name"
          :value="item.Price + '元/' + item.Unit"
          :key="index"
        />
      </van-tab>
      <van-tab title="药品价格">
        <van-search
          placeholder="请输入要查询的药品名称"
          v-model="YaoJia_val"
          @search="YaoJia_soso"
        />
        <van-cell
          v-for="(item, index) of YaoJia_data"
          :title="item.CommonName"
          :value="item.Lsj + '元/' + item.YfUnit"
          size="large"
          :label="'规格:' + item.Gg + ' 剂型:' + item.JXName"
          :key="index"
        />
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
export default {
  name: "wujia",
  data() {
    return {
      active: 0,
      FuWuSoso_val: "",
      YaoJia_val: "",
      FuWuSoso_data: {},
      YaoJia_data: {},
    };
  },
  created() {
    console.log(window.localStorage.getItem("user_token"));
  },
  methods: {
    FuWuSoso_soso() {
      if (this.FuWuSoso_val) {
        this.http
          .post("/app/wechat/Wujiacha/yiliaofuwu/mid/2", {
            soso: this.FuWuSoso_val,
          })
          .then((res) => {
            if (res.data.error == 0) {
              this.FuWuSoso_data = res.data.info;
            } else {
              this.FuWuSoso_data = [];
            }
          });
      }
    },
    YaoJia_soso() {
      if (this.YaoJia_val) {
        this.http
          .post("/app/wechat/Wujiacha/yaopingjia/mid/2", {
            soso: this.YaoJia_val,
          })
          .then((res) => {
            if (res.data.error == 0) {
              this.YaoJia_data = res.data.info;
            } else {
              this.YaoJia_data = [];
            }
          });
      }
    },
  },
};
</script>

<style scoped>
.van-cell__value {
  color: red;
}
.van-cell__title {
  min-width: 250px;
}
</style>
